﻿using MediatR;
using Traceability.Commont.Domains.BatchManagementFiles;
using Traceability.Commont.DTOs.BatchManagementDTOs;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.BatchManagements
{
    public class WhiteCreateListHander : IRequestHandler<WhiteCreateListCommand, Resqults<WhiteListDTo>>
    {
        private readonly IBateRepository<Byproduct> bateRepository;

        public WhiteCreateListHander(IBateRepository<Byproduct> bateRepository)
        {
            this.bateRepository = bateRepository;
        }

        public async Task<Resqults<WhiteListDTo>> Handle(WhiteCreateListCommand request, CancellationToken cancellationToken)
        {
            try
            {
                Resqults<WhiteListDTo> res = new Resqults<WhiteListDTo>();
                var list = from a in bateRepository.GetAll()
                           select new WhiteListDTo()
                           {
                               ByID=a.ByproductId,
                               Stashid="副产1库",
                               DocumentsNo=a.DocumentsNo,
                               ByproductDate=a.ByproductDate,
                               ShoppingType=a.ShoppingType,
                               byproductNum=a.byproductNum,
                               byproductNoteWeight=a.byproductNoteWeight,
                               byproductNoteTare=a.byproductNoteTare,
                               byproductNetWeight=a.byproductNetWeight,
                               Rremark = a.Rremark
                           };
                res.Date = list.ToList();
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
